[PATCH] GNU/Hurd: Add getExecutablePath support
authorSamuel Thibault <samuel.thibault@ens-lyon.org>
Sun, 15 Sep 2024 13:57:52 +0000 (15:57 +0200)
committerIlias Tsitsimpis <iliastsi@debian.org>
Sat, 24 Jan 2026 12:41:42 +0000 (14:41 +0200)
GNU/Hurd exposes it as /proc/self/exe just like on Linux.

Gbp-Pq: Name gnu-hurd

libraries/ghc-internal/src/GHC/Internal/System/Environment/ExecutablePath.hsc

index a06b39f8f8b6ec48008dbe867b475b95a6d456c3..6eb40c851fa81c34effb876f738effd3770a1273 100644 (file)
@@ -200,9 +200,9 @@ executablePath = Just (fmap Just getExecutablePath `catch` f)
       | otherwise             = throw e
 
 --------------------------------------------------------------------------------
--- Linux / Solaris
+-- Linux / Solaris / Hurd
 
-#elif defined(linux_HOST_OS) || defined(solaris2_HOST_OS)
+#elif defined(linux_HOST_OS) || defined(solaris2_HOST_OS) || defined(gnu_HOST_OS)
 
 foreign import ccall unsafe "readlink"
     c_readlink :: CString -> CString -> CSize -> IO CInt
@@ -219,7 +219,7 @@ readSymbolicLink file =
                    c_readlink s buf 4096
             peekFilePathLen (buf,fromIntegral len)
 
-#  if defined(linux_HOST_OS)
+#  if defined(linux_HOST_OS) || defined(gnu_HOST_OS)
 getExecutablePath = readSymbolicLink $ "/proc/self/exe"
 
 executablePath = Just (check <$> getExecutablePath) where